﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reactive.Linq;
using System.Reactive.Threading.Tasks;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Exercises
{

    [TestClass]
    public class ObservingTasks
    {
        [TestMethod]
        public void TestMethod()
        {
            //initialize
            double angle = 30;
            var tCos = Task.Factory.StartNew(() => Math.Cos(angle));
            var tSin = Task.Factory.StartNew(() => Math.Sin(angle));

            //execute
            var result = from x in tCos.ToObservable()
                         from y in tSin.ToObservable()
                         select x * y;
            result.Subscribe(x => Debug.WriteLine(x));

            //assert
            Thread.Sleep(100);
        }
    }
}
